package com.beaven.imserver.net.bean.api.user;

import com.beaven.imserver.net.bean.db.User;
import com.google.common.base.Strings;
import com.google.gson.annotations.Expose;

/**
 * author: Beaven
 * time: 2017/5/18 11:54
 *
 * 用户更新信息
 */
public class UpdateInfoModel {

  @Expose
  private String name;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  /**
   * 把当前的信息，填充到用户Model中
   * 方便UserModel进行写入
   *
   * @param user User Model
   * @return User Model
   */
  public User updateToUser(User user) {
    if (!Strings.isNullOrEmpty(name)) {
      user.setName(name);
    }
    return user;
  }

  public static boolean check(UpdateInfoModel model) {
    return model != null && (!Strings.isNullOrEmpty(model.name));
  }
}
